#!/usr/bin/python3


import json
import glob
import os
import time

print("List: ")
files=glob.glob("*.json")

def key(f):
    # os.path.join(directory, filename)
    return os.path.getmtime(f)

files=sorted(files,key=key)

def strftime(t):
    return time.strftime("%Y-%m-%d %X",time.localtime(t))


print("<ol>")
count=0
for f in files:
    jo={}
  
    try:
        with open(f,"r") as fd:
            jo=json.load(fd)
        title=jo.get("vod_name",f)
        # id=jo.get("vod_actor",f)
        id=f.split("_")[-1].split(".")[0]
        director=jo.get("vod_director",f)
        url=f"https://www.bilibili.com/video/av{id}"
        # xx.lower().startswith("bv")
        if id.lower().startswith("bv"):
            url=f"https://www.bilibili.com/video/{id}"
        else:
            url=f"https://www.bilibili.com/video/av{id}"
        
        print(f"<li>{strftime(key(f))}\t \t<a href=\"{url}\">{id}</a> {director}\t<-->\t{title[:50]}</li>")
        count+=1
        if count%10==0:
            print("</ol>")
            print("<ol>")
    except:
        pass
print("</ol>")

